<?php

class Somi_Form_Firmapasswort extends Zend_Dojo_Form
{
	public function init()
	{
		
		$this->setName('firmendaten');
		$this->setAction($this->getView()->url())->setMethod('post');
		$this->addAttribs(array('onSubmit'=>'return validate(this)'));
		
		require_once APPLICATION_BASE.'/library/Somi/Validate/ErrorMessageDe.php';
		require_once APPLICATION_BASE.'/library/Somi/Validate/PasswordConfirmation.php';
		require_once APPLICATION_BASE.'/library/Somi/Validate/PasswordCurrentCheck.php';
		
		$translateValidators= new Somi_Validate_ErrorMessageDe();
		$translator = new Zend_Translate('array', $translateValidators->getTranslate());
    	Zend_Validate_Abstract::setDefaultTranslator($translator);
    	
    	    	
    	#$this->clearDecorators();
		$formDecorators=array(
		'formElements',
		array('HtmlTag',array('tag'=>'dl','class'=>'zend_form')),
		'Form',
		);
		
		$elementDecorators=array(
		'ViewHelper',
		'Errors',
		array(array('data'=>'HtmlTag'),array('tag'=>'div','class'=>'element')),
		array('Label',array('class'=>'left','requiredSuffix' => '*')),
		array(array('row'=>'HtmlTag'),array('tag'=>'div','class'=>'row')),
		);
		
		$buttonDecorators=array(
		'ViewHelper',
		array(array('data'=>'HtmlTag'),array('tag'=>'div','class'=>'buttonrow')),
		array(array('row'=>'HtmlTag'),array('tag'=>'div'))
		);
        

		
	
		$filterToLower = new Zend_Filter_StringToLower();
        $filterToLower->setEncoding('UTF-8');
        
        
		# Password
		$password=new Zend_Form_Element_Password('password');
		$password->setLabel('Neues Passwort')
		->setRequired(true)
		->setDescription('mindestens 6 zeichen')
		->addFilter('StripTags')
		->addFilter('StringTrim');
		$password->addPrefixPath('Somi_Validate', APPLICATION_BASE.'/library/Somi/Validate/PasswordConfirmation.php', 'validate');
		$password->addValidator('PasswordConfirmation', false, array('passwordConf'));
		$password->addValidator('StringLength', true, array(6, 15));
		$password->setAttrib('class','password');
		
		
		# Password Confirm
		$passwordConf=new Zend_Form_Element_Password('passwordConf');
		$passwordConf->setLabel('Passwort bestätigen')
		->setRequired(true)
		->setDescription('Passwort wiederholen')
		->addFilter('StripTags')
		->addFilter('StringTrim');
		$passwordConf->setAttrib('class','passwordConf');
		
		
		# password current
		$passwordCur=new Zend_Form_Element_Password('passwordCur');
		$passwordCur->setLabel('Aktuelles Passwort')
		->setRequired(true)
		->addFilter('StripTags')
		->addFilter('StringTrim')
		->setDescription('deine aktulle Passwort');
		$passwordCur->addPrefixPath('Somi_Validate', APPLICATION_BASE.'/library/Somi/Validate/PasswordCurrentCheck.php', 'validate');
		$passwordCur->addValidator('PasswordCurrentCheck', false);
		$passwordCur->setAttrib('class','passwordCur');
		
		
		#Submit
		$submit=new Zend_Form_Element_Submit('submit');
		$submit->setLabel('speichern');
		$submit->setAttrib('id','submitbutton');
		$submit->setAttrib('style','margin-left:150px;width:245px;');
		#$submit->setAttrib('class','form-button-left');
		
		
		
		# Send Elements
		$this->addElements(array($passwordCur,$password,$passwordConf,$submit));
		
		#$this->addDisplayGroup(array('password','passwordConf','passwordCur'),'passwort');
		
		$this->setDecorators($formDecorators);
		$this->setElementDecorators($elementDecorators);
		$this->getElement('submit')->setDecorators($buttonDecorators);
        
	
	}
}